#注意，这一步不是加载图像
import networkx as nx
import matplotlib.pyplot as plt
import pickle
f= open('savegraph.pickle','rb')
G = pickle.load(f)
f.close()

edge_labels = dict([((u, v,), d['weight'])
                    for u, v, d in G.edges(data=True)])
red_edges = [('C', 'D'), ('D', 'A')]
edge_colors = ['black' if not edge in red_edges else 'red' for edge in G.edges()]
pos = nx.spring_layout(G)
nx.draw(G, pos, node_color='yellow', node_size=1500, edge_color=edge_colors)
nx.draw_networkx_labels(G, pos, font_size=20, font_family='sans-serif')

nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)

f = open('savegraph.pickle','wb')
pickle.dump(G,f,protocol=pickle.HIGHEST_PROTOCOL)
f.close()
plt.show()